import service from './interceptors';

const request = {
  /**
     * 基础post,get请求接口。
     * post请求数据分为:
     * 1.添加到请求体（ body） postData
     * 2.添加到url的请求字符串中的 post
     * @param  {string} url 请求的接口
     * @param  {json} reqData  post 类型传递的数据
     */
  post(url, questData) {
    return new Promise(function (resolve, reject) {
      return service({
        method: 'POST',
        url,
        params: questData
      }).then(res => {
        resolve(res)
      }).catch((err) => {
        reject(err)
      })
    })
  },
  postData(url, questData) {
    return new Promise(function (resolve, reject) {
      return service({
        method: 'POST',
        url,
        data: questData,

      }).then(res => {
        resolve(res)
      }).catch((err) => {
        reject(err)
      })
    })
  },
  get(url, questData) {
    return new Promise(function (resolve, reject) {
      return service({
        method: 'GET',
        url,
        params: questData
      }).then(res => {
        resolve(res)
      }).catch((err) => {
        reject(err)
      })
    })
  },
  delete(url, questData) {
    return new Promise(function (resolve, reject) {
      return service({
        method: 'delete',
        url,
        data: questData
      }).then(res => {
        resolve(res)
      }).catch((err) => {
        reject(err)
      })
    })
  },
  put(url, questData) {

  }
}

export default request;